﻿using OASystem.BLL.Service;
using OASystem.Model;
using OASystem.Models;
using OASystem.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace OASystem.Controllers
{
    public class RoleController : Controller
    {
        public static Position position;
        private RoleService service = new RoleService();
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public JsonResult RolePageList(int page, int limit, string username)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult.data = service.RolePageList(page, limit, username);
            return Json(responseResult.data, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 删除用户信息
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        public JsonResult DelectRole(Position position)
        {
            Operate operate = new Operate();
            operate.Success = service.Delete(position);
            return Json(operate);
        }
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="function"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult UpdateRole(Position position)
        {
            Operate operate = new Operate();
            operate.Success = service.Update(position);
            return Json(operate);
        }
        /// <summary>
        /// 显示编辑数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult Update(int id)
        {
            ResponseResult responseResult = new ResponseResult();
            responseResult= service.Update(id);
            position = responseResult.data as Position;
            return Json(responseResult);
        }
        /// <summary>
        /// 用户管理批量删除
        /// </summary>
        /// <param name="sqlBywhereId"></param>
        /// <returns></returns>
        public JsonResult MoreDel(string id)
        {
            ResponseResult result = new ResponseResult();
            result = service.MoreDel(id);
            return Json(result);
        }
        
    }
}